﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using MySql.Data.MySqlClient;
using Models;
using DAL;

namespace BLL
{
    public class CharInfoManager
    {
        CharInfoService cis = new CharInfoService();
        public Characters GetCharInfo(string id)
        {
            return cis.GetCharInfo(id);
        }

        public string GetMapNameBYMapId(int mapid)
        {
            //获取角色所在的地图名称
            return cis.GetMapNameBYMapId(mapid);
        }

        public DataView GetAllItem(string id,int type)
        {
            //背包物品
            DataView dvItem = new DataView();
            switch (type)
            {
                case 1:
                    dvItem.Table = dvItem.Table = cis.GetAllItem(id, 1).Tables["CharItem"];
                    break;
                case 2:
                    dvItem.Table = dvItem.Table = cis.GetAllItem(id, 2).Tables["CharItem"];
                    break;
                case 3:
                    dvItem.Table = dvItem.Table = cis.GetAllItem(id, 3).Tables["CharItem"];
                    break;
                case 4:
                    dvItem.Table = dvItem.Table = cis.GetAllItem(id, 4).Tables["CharItem"];
                    break;
            }
            dvItem.Sort = "count desc";
            return dvItem;
        }

        public bool DeleteItem(string id,int type)
        {
            if (cis.DeleteItem(id,type))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool AllDeleteItem(string id, int type)
        {
            if (cis.AllDeleteItem(id, type))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool CharAux(string a, int type)
        {
            if (cis.CharAux(a, type))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool SetCharInfo(int str, int con, int dex, int cha, int intel, int wis, int sex, string name)
        {
            if (cis.SetCharInfo(str, con, dex,cha,intel,wis,sex,name))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
